﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using blackenter.Business.Pages;
using blackenter.Business.Sites;

namespace blackenter.Business.Observables {
    internal class LanguagePageObserver {

        internal void Observe() {
            CmsSiteLanguage.LanguageChangeObservable += CmsSiteLanguage_LanguageChangeObservable;
        }

        void CmsSiteLanguage_LanguageChangeObservable(object sender, LanguageEventArgs e) {
            var pages = new CmsPages(e.SiteId, CultureInfo.InvariantCulture);
            foreach (var cmsPage in pages) {
                cmsPage.SiteCulture = e.Culture;
                cmsPage.Save();
            }
        }

    }
}
